<template>
	<view class="tgqrcode">
		<view class="code_bg">
			<image :src="qrcode"></image>
			<view class="code_name">{{username}}</view>
			<view>业务码 {{usercode}}</view>
		</view>
	</view>
</template>

<script>
	import { userqrmsg } from '../../api/index.js'
	import config from '../../util/config.js'
	export default {
		data() {
			return {
				qrcode:'../../static/img/my.png',
				username:'',
				usercode:'',
				location:{}
			}
		},
		onLoad:function(){
			let that = this;
			let id = this.$storage('global').getItemSync('loginInfo').aid;
			console.log(id)
			that.qrcode = config.mengxiaoer.BASE_URL + config.mengxiaoer.RETAIL + config.mengxiaoer.VERSION_CODE + '/userqrimg?aid=' + id;
			console.log(that.qrcode)
			cm.getLocations({
				success:function(res){
					console.log(res)
					that.location = res;
					that.getUserqrmsg();
				}
			});
		},
		methods: {
			getUserqrmsg:function(){
				let that = this;
				let obj = {
					longitude:that.location.longitude,
					latitude:that.location.latitude
				}
				userqrmsg(obj).then((res) => {
					that.username = res.data.realname;
					that.usercode = res.data.aid;
				}).catch((e) => {
					console.log(e)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tgqrcode{
		height: 100%;
		background-color: #007AFF;
		padding-top: 20rpx;
		font-size: $uni-font-size-base;
		.code_bg{
			margin: 0 auto;
			width: 90%;
			height: 700rpx;
			background-image: url('../../static/img/ic_qrcodebg.png');
			background-size: 100% 100%;
			text-align: center;
			padding-top: 100rpx;
			image{
				width: 420rpx;
				height: 420rpx;
			}
			.code_name{
				margin-top: 80rpx;
				font-weight: bold;
			}
		}
	}
</style>
